package com.twu.biblioteca;

import java.io.IOException;
public class menuOnStartup {

    private bookCatalogue collection;
    private movieCatalogBuilder movieCatalog;
    private userStore usersList;
    public  menuOnStartup(bookCatalogue current, movieCatalogBuilder currentMovies,userStore usersToAdd){
        collection = new bookCatalogue();
        movieCatalog = new movieCatalogBuilder();
        usersList = new userStore();
        movieCatalog = currentMovies;
        collection = current;
        usersList = usersToAdd;
    }
     //access a global book and movie catalog instead of passing from main function. Think of workaround

    // Prints startup Menu
    public void printMenu(){
        System.out.println("Welcome to Bangalore Public Library!\n" +
                "Choose from the following options by entering the option number\n" +
                "1\tView list of all books\n" +
                "2\tReserve a book for Collection\n" +
                "3\tSee Membership Details\n" +
                "4\tView list of Movies\n" +
                "Enter your choice here: ");
    }

    //validate user input
    public void isOptionValid(int testInt) throws IOException{

        boolean isUserLoggedIn;
        userInstance loggedInUser;
        if(testInt ==2||testInt==3)
            isUserLoggedIn = usersList.doLogin();
        else
            isUserLoggedIn = false;

        switch (testInt){
                case 1:
                    displayStock displayChosen = new displayStock(collection);
                    displayChosen.display();
                    break;
                case 2:
                    if(isUserLoggedIn){
                        bookReservation reserver = new bookReservation(collection);
                        reserver.getBookFromUser();
                    }
                    break;
                case 3:
                    if(isUserLoggedIn){
                        loggedInUser = usersList.getLoggedInUser();
                        System.out.print("Username\t"+loggedInUser.getUsername()+
                                "\nEmail Id\t"+loggedInUser.getAccountEmail()+
                                "\nPhone Number\t"+loggedInUser.getPhoneNumber());
                    }
                    else
                        System.out.print("Please talk to a librarian. Thank you");
                    break;
                case 4:
                    movieCatalog.viewMovieList();
                    break;
                default:
                    System.out.print("Invalid Option Selected");
            }

    }
}
